package com.ruoyi.web.controller.production.carton;

import java.util.List;

import com.ruoyi.common.annotation.PropertyInject;
import com.ruoyi.common.enums.InjectType;
import io.swagger.annotations.Api;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.production.domain.carton.CartonAmount;
import com.ruoyi.production.service.carton.ICartonAmountService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 纸箱量Controller
 *
 * @author ruoyi
 * @date 2021-07-10
 */
@RestController
@RequestMapping("/system/cartonAmount")
@Api(value = "纸箱量",tags = "纸箱量相关API")
public class CartonAmountController extends BaseController
{
    @Autowired
    private ICartonAmountService cartonAmountService;

    /**
     * 查询纸箱量列表
     */
    @PreAuthorize("@ss.hasPermi('system:cartonAmount:list')")
    @GetMapping("/list")
    public TableDataInfo list(CartonAmount cartonAmount)
    {
        startPage();
        List<CartonAmount> list = cartonAmountService.selectCartonAmountList(cartonAmount);
        return getDataTable(list);
    }

    /**
     * 导出纸箱量列表
     */
    @PreAuthorize("@ss.hasPermi('system:cartonAmount:export')")
    @Log(title = "纸箱量", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CartonAmount cartonAmount)
    {
        List<CartonAmount> list = cartonAmountService.selectCartonAmountList(cartonAmount);
        ExcelUtil<CartonAmount> util = new ExcelUtil<CartonAmount>(CartonAmount.class);
        return util.exportExcel(list, "纸箱量数据");
    }

    /**
     * 获取纸箱量详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:cartonAmount:query')")
    @GetMapping(value = "/{cartonAmountId}")
    public AjaxResult getInfo(@PathVariable("cartonAmountId") Long cartonAmountId)
    {
        return AjaxResult.success(cartonAmountService.selectCartonAmountById(cartonAmountId));
    }

    /**
     * 新增纸箱量
     */
    @PreAuthorize("@ss.hasPermi('system:cartonAmount:add')")
    @Log(title = "纸箱量", businessType = BusinessType.INSERT)
    @PostMapping
    @PropertyInject(type = InjectType.Insert)
    public AjaxResult add(@RequestBody CartonAmount cartonAmount)
    {
        return toAjax(cartonAmountService.insertCartonAmount(cartonAmount));
    }

    /**
     * 修改纸箱量
     */
    @PreAuthorize("@ss.hasPermi('system:cartonAmount:edit')")
    @Log(title = "纸箱量", businessType = BusinessType.UPDATE)
    @PutMapping
    @PropertyInject(type = InjectType.Update)
    public AjaxResult edit(@RequestBody CartonAmount cartonAmount)
    {
        return toAjax(cartonAmountService.updateCartonAmount(cartonAmount));
    }

    /**
     * 删除纸箱量
     */
    @PreAuthorize("@ss.hasPermi('system:cartonAmount:remove')")
    @Log(title = "纸箱量", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cartonAmountIds}")
    public AjaxResult remove(@PathVariable Long[] cartonAmountIds)
    {
        return toAjax(cartonAmountService.deleteCartonAmountByIds(cartonAmountIds));
    }
}
